package com.oocl.sc.action;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.oocl.sc.service.SuserService;
import com.oocl.sc.service.impl.SuserServiceImpl;

public class RegisterAction extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	private static final String SUCCESS = "{\"status\":\"1\"}";
	private static final String FAIL = "{\"status\":\"-1\"}";
	SuserService suserService = new SuserServiceImpl();
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String account = request.getParameter("account");
		String password = request.getParameter("password");
		if (account!=null && password!=null){
			int status = suserService.register(account, password);
			if(status == 1){
				response.getWriter().write(SUCCESS);
			}else{
				response.getWriter().write(FAIL);
			}
		}
		
	}

}
